# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-mgba
pkgver=0.8.4.19
_realname=Matrix
pkgrel=1
pkgdesc="mGBA for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.mgba"
arch="x86 x86_64 aarch64 armv7" # kodi
license="MPL-2.0"
makedepends="cmake kodi-dev"
depends="kodi-game-libretro libretro-mgba"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.mgba/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.mgba-$pkgver-$_realname"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.mgba/resources/icon.png \
		"$pkgdir"/usr/share/kodi/addons/game.libretro.mgba/resources/screenshot* \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.mgba/game.libretro.mgba.so
	ln -s /usr/lib/libretro/mgba_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.mgba/game.libretro.mgba.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.mgba/addon.xml
}

sha512sums="380e7737af4eea765e843424345ccd2efce2e93bc21a207e2f865037323819f2a9935984c10b5ee21d04599ae9b7e97fc54a1574c528a5b4b2998fd79578edca  kodi-game-libretro-mgba-0.8.4.19-Matrix.tar.gz"
